package com.sy.utils;

import java.util.Random;

/**
 * @className: StringRandom
 * @author: Mr.Liu
 * @date: 2025/10/29 14:50
 * @Version: 1.0
 * @description:随机生成字符串(用户名)
 */
public class StringRandom {
    //随机生成用户名
    public static String randomName(){
        //定义空字符串
        StringBuffer sb = new StringBuffer("");
        String val="abcdefghijklmnopqrstuvdxyzABCDEFGHIGKLMNOPQRSTUVWXYZ0123456789";
        for (int i = 0; i < 6; i++) {
            Random r = new Random();
            //随机索引
            int index = r.nextInt(val.length());
            sb.append(val.charAt(index));
        }
        return sb.toString();
    }
}
